import Vue from 'vue'
import Router from 'vue-router'
import Apply from './views/apply.vue'
import Applied from './views/applied.vue'
import Preview from './views/preview.vue'
import Detail from './views/detail.vue'
import Locked from './views/locked.vue'
import Expelled from './views/expelled.vue'
import Invalid from './views/invalid.vue'
import Share from './views/share.vue'
import Game from './views/game.vue'

Vue.use(Router)

export default new Router({
    // mode: 'history',
    base: process.env.BASE_URL,
    routes: [
    {
        path: '/',
        redirect: '/preview',
    },
    {
        path: '/apply/:id',
        name: 'apply',
        meta: {
            title: '报名学习'
        },
        component: Apply
    },
    {
        path: '/applied',
        name: 'applied',
        meta: {
            title: '注册申请'
        },
        component: Applied
    },
    {
        path: '/preview',
        name: 'preview',
        meta: {
            title: '课程列表'
        },
        component: Preview,
        props: route => ({ 
            holderId: route.query.hId,
            self: route.query.self,
        }),
    },
    {
        path: '/game',
        name: 'game',
        component: Game,
        props: route => ({ 
            url: route.query.url,
        }),
        meta: {
            title: '跳转游戏'
        }
    },
    {
        path: '/detail/:id',
        name: 'detail',
        component: Detail,
        props: route => ({ 
            holderId: route.query.hId,
        }),
        meta: {
            title: '课程列表'
        }
    },{
        path: '/locked/:id',
        name: 'locked',
        meta: {
            title: '访问失败'
        },
        component: Locked
    },{
        path: '/expelled/:id',
        name: 'expelled',
        meta: {
            title: '访问失败'
        },
        component: Expelled
    },{
        path: '/invalid',
        name: 'invalid',
        meta: {
            title: '访问失败'
        },
        component: Invalid
    }, {
        path: '/share',
        name: 'share-code',
        component: Share,
        props: route => ({ 
            holderId: route.query.hId,
            parentCustomerId: route.query.pId,
            customerId: route.query.cId,
            time: route.query.time
        }),
        meta: {
            title: '课程海报'
        }
    }]
})